package com.yc.sole.job;

import com.yc.sole.erp.dto.ProduceDto;
import com.yc.sole.erp.dto.SaleOrderDto;
import com.yc.sole.erp.enums.OrderState;
import com.yc.sole.erp.repository.ProduceRepository;
import com.yc.sole.erp.repository.SaleOrderRepository;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author yizuomin
 * @date 2024/1/27 15:19
 **/
@Slf4j
@Component
@RequiredArgsConstructor
public class OrderStateJob {

    private final ProduceRepository produceRepository;
    private final SaleOrderRepository saleOrderRepository;

    @Scheduled(cron = "0 30 9,21 * * ?")
    @Transactional(rollbackFor = Exception.class)
    public void run() {
        log.info("变更订单状态-开始执行");
        // 1查询订单
        List<SaleOrderDto> saleOrderDtoList = saleOrderRepository.selectAllUnFinishedOrder();
        // 2查询回款
        // 3判断回款金额
        log.info("变更订单状态-执行结束");
    }
}
